<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/testTpl1.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>TestPage</title>
    <!-- InstanceEndEditable -->
    <!-- InstanceBeginEditable name="head" -->
    <!-- InstanceEndEditable -->
    <link rel="stylesheet" type="text/css" href="../style/google/KitchenSink.css">
    <!-- InstanceBeginEditable name="additionalStyle" -->
    <!-- InstanceEndEditable -->

    <script type="text/javascript">
    var djConfig = {
        isDebug: true
        ,debugAtAllCosts: true
    };
    </script>

    <script type="text/javascript" src="../../../trimpath/template-1.0.38.js"></script>
    <script type="text/javascript" src="../../../dojo/deploy/dojo.js"></script>
    <script type="text/javascript" src="../../dojo-lotex.js"></script>
    <script type="text/javascript" src="../../../fckeditor/fckeditor.js"></script>

    <!-- InstanceBeginEditable name="dojoRequire" -->

    <script type="text/javascript">
    dojo.require("lotex.system.Loader");

    dojo.hostenv.writeIncludes();
    </script>

    <!-- InstanceEndEditable -->
    <!-- InstanceBeginEditable name="headScript" -->

    <script type="text/javascript">

// FCKeditor_OnComplete is a special function that is called when an editor
// instance is loaded ad available to the API. It must be named exactly in
// this way.
function FCKeditor_OnComplete( editorInstance )
{
    // Show the editor name and description in the browser status bar.
    document.getElementById('eMessage').innerHTML = 'Instance "' + editorInstance.Name + '" loaded - ' + editorInstance.Description ;

    // Show this sample buttons.
    document.getElementById('eButtons').style.visibility = '' ;
}

function InsertHTML()
{
    // Get the editor instance that we want to interact with.
    var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;

    // Check the active editing mode.
    if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
    {
        // Insert the desired HTML.
        oEditor.InsertHtml( '- This is some <a href="/Test1.html">sample</a> HTML -' ) ;
    }
    else
        alert( 'You must be on WYSIWYG mode!' ) ;
}

function SetContents()
{
    // Get the editor instance that we want to interact with.
    var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;

    // Set the editor contents (replace the actual one).
    oEditor.SetHTML( 'This is the <b>new content</b> I want in the editor.' ) ;
}

function GetContents()
{
    // Get the editor instance that we want to interact with.
    var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;

    // Get the editor contents in XHTML.
    alert( oEditor.GetXHTML( true ) ) ;     // "true" means you want it formatted.
}

function ExecuteCommand( commandName )
{
    // Get the editor instance that we want to interact with.
    var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;

    // Execute the command.
    oEditor.Commands.GetCommand( commandName ).Execute() ;
}

function GetLength()
{
    // This functions shows that you can interact directly with the editor area
    // DOM. In this way you have the freedom to do anything you want with it.

    // Get the editor instance that we want to interact with.
    var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;

    // Get the Editor Area DOM (Document object).
    var oDOM = oEditor.EditorDocument ;

    var iLength ;

    // The are two diffent ways to get the text (without HTML markups).
    // It is browser specific.

    if ( document.all )     // If Internet Explorer.
    {
        iLength = oDOM.body.innerText.length ;
    }
    else                    // If Gecko.
    {
        var r = oDOM.createRange() ;
        r.selectNodeContents( oDOM.body ) ;
        iLength = r.toString().length ;
    }

    alert( 'Actual text length (without HTML markups): ' + iLength + ' characters' ) ;
}

function GetInnerHTML()
{
    // Get the editor instance that we want to interact with.
    var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;

    alert( oEditor.EditorDocument.body.innerHTML ) ;
}

function CheckIsDirty()
{
    // Get the editor instance that we want to interact with.
    var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
    alert( oEditor.IsDirty() ) ;
}

function ResetIsDirty()
{
    // Get the editor instance that we want to interact with.
    var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
    oEditor.ResetIsDirty() ;
    alert( 'The "IsDirty" status has been reset' ) ;
}

    </script>

    <!-- InstanceEndEditable -->
</head>
<body>
    <table style="width: 100%" cellspacing="0" cellpadding="0">
        <tbody>
            <tr>
                <td style="vertical-align: top" align="left">
                    <div class="ks-Info">
                        Testpage</div>
                </td>
            </tr>
            <tr>
                <td style="vertical-align: top" align="left">
                    <table class="ks-Sink" cellspacing="0" cellpadding="0">
                        <tbody>
                            <tr>
                                <td style="vertical-align: top; width: 100%; height: 100%" align="left">
                                    <div id="container">
                                        <!-- InstanceBeginEditable name="htmlContainer" -->
    <form action="sampleposteddata.asp" method="post" target="_blank">
        <script type="text/javascript">
<!--
// Automatically calculates the editor base path based on the _samples directory.
// This is usefull only for these samples. A real application should use something like this:
// oFCKeditor.BasePath = '/fckeditor/' ;    // '/fckeditor/' is the default value.
var sBasePath = "file:///D:/rptp/trunk/ajaj/fckeditor/";

var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ;
var sSkin = "office2003" ;
if ( sSkin != null )
{
    var sSkinPath = sBasePath + 'editor/skins/' + sSkin + '/' ;
    d(sSkinPath);
    oFCKeditor.Config['SkinPath'] = sSkinPath ;

    // The following switch is optional. It is done to enhance the loading
    // time of the toolbar, by preloading the images used on it.
    switch ( sSkin )
    {
        case 'office2003' :
            oFCKeditor.Config['PreloadImages'] =
                sSkinPath + 'images/toolbar.start.gif' + ';' +
                sSkinPath + 'images/toolbar.end.gif' + ';' +
                sSkinPath + 'images/toolbar.bg.gif' + ';' +
                sSkinPath + 'images/toolbar.buttonarrow.gif' ;
            break ;

        case 'silver' :
            oFCKeditor.Config['PreloadImages'] =
                sSkinPath + 'images/toolbar.start.gif' + ';' +
                sSkinPath + 'images/toolbar.end.gif' + ';' +
                sSkinPath + 'images/toolbar.buttonbg.gif' + ';' +
                sSkinPath + 'images/toolbar.buttonarrow.gif' ;
            break ;
    }
}
oFCKeditor.BasePath = sBasePath ;
oFCKeditor.Height   = 300 ;
oFCKeditor.Value    = 'This is some <strong>sample text<\/strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor<\/a>.' ;
oFCKeditor.Create() ;
//-->
        </script>
        <br />
        <!-- input type="submit" value="Submit" / -->
    <div id="eMessage">
        &nbsp;
    </div>
    <div id="eButtons" style="visibility: hidden">
        <input type="button" value="Insert HTML" onclick="InsertHTML();" />
        <input type="button" value="Set Editor Contents" onclick="SetContents();" />
        <input type="button" value="Get Editor Contents (XHTML)" onclick="GetContents();" />
        <br />
        <br />
        <input type="button" value='Execute "Bold" Command' onclick="ExecuteCommand('Bold');" />
        <input type="button" value='Execute "Link" Command' onclick="ExecuteCommand('Link');" />
        <br />
        <br />
        <input type="button" value="Interact with the Editor Area DOM" onclick="GetLength();" />
        <input type="button" value="Get innerHTML" onclick="GetInnerHTML();" />
        <br />
        <br />
        <input type="button" value="Check IsDirty()" onclick="CheckIsDirty();" />
        <input type="button" value="Reset IsDirty()" onclick="ResetIsDirty();" />
    </div>
    </form>
                                        <!-- InstanceEndEditable -->
                                    </div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </td>
            </tr>
        </tbody>
    </table>
    <fieldset>
        <legend>Output</legend>
        <div id="debug.output">
        </div>
    </fieldset>
</body>
<!-- InstanceEnd --></html>
